import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/home.vue'
import indexView from '@/views/home/index.vue'
import calView from '@/views/home/cal.vue'
import cartView from '@/views/home/cart.vue'
import myView from '@/views/home/my.vue'
import zcView from '@/views/home/zc.vue'
import dlView from '@/views/home/dl.vue'
import ddlbView from '@/views/home/ddlb.vue'
import ddxqView from '@/views/home/ddxq.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/', redirect: '/home/index'
    },
    {
      path: '/home', component: HomeView, children: [
        { path: 'index', component: indexView },
        { path: 'cal', component: calView },
        { path: 'cart', component: cartView },
        { path: 'my', component: myView },
      ]
    },
    {
       path: '/zc', component: zcView
    },
    {
       path: '/dl', component: dlView
    },
    {
       path: '/ddlb', component: ddlbView
    },
     {
       path: '/ddxq', component: ddxqView
    },
  ],
})
// router.beforeEach((to, from, next) => {
//   let token = localStorage.getItem('token')
//    if(to.fullPath=='/home/cart'||to.fullPath=='/home/my'){
//      if(!token){
//        next('/dl')
//      }else{
//       next()
//      }
//    }else{
//     next()
//    } 
// })
export default router
